package com.haian.slidealbum.control;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

public class WidgetProvider extends AppWidgetProvider {

	public static int appWidgetId;
	
	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		try {
			if (appWidgetIds == null) {
				appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(
						context, WidgetProvider.class));
			}
			for (int appWidgetIdCurrent : appWidgetIds) {
				Intent intent = new Intent(context, WidgetUpdateService.class);
				appWidgetId = appWidgetIdCurrent;
				intent.putExtra("appWidgetId", appWidgetId);
				context.startService(intent);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
